<template>
  <section style="padding-bottom: 10px;">
    <img src="../../assets/credit/bg.png" width="100%" style="display: block;"/>
    <div class="part">
      <div class="part_top">
        <div class="tp_left">
          <p class="tit">
            <img src="../../assets/index/line.png" class="title_index_img">
            <span>风险审核报告（精简版）</span>
          </p>
          <p class="con">身份证核验返照+通信小号核验+不良信息核验+逾期黑名单核验</p>
          <p class="look"><span @click="lookBtn1()" style="font-size: .24rem;">查看报告示例</span></p>
        </div>
        <img src="../../assets/credit/simple.png" class="img">
      </div>
      <div class="line"></div>
      <div class="part_bot">
        <p>
          <span>￥{{price1}}</span><span>元</span>
          <span>原价￥10.0元</span>
        </p>
        <yd-button type="danger" @click.native="searchBtn1()">点击查询</yd-button>
      </div>
    </div>

    <div class="part">
      <div class="part_top">
        <div class="tp_left">
          <p class="tit">
            <img src="../../assets/index/line.png" class="title_index_img">
            <span>风险审核报告（详细版）</span>
          </p>
          <p class="con">身份证核验返照+通信小号核验+不良信息核验+逾期黑名单核验+逾期金额时长等详情+逾期催收详情+多头借贷核验</p>
          <p class="look"><span @click="lookBtn2()" style="font-size: .24rem;">查看报告示例</span></p>
        </div>
        <img src="../../assets/credit/complex.png" class="img">
      </div>
      <div class="line"></div>
      <div class="part_bot">
        <p>
          <span>￥{{price2}}</span><span>元</span>
          <span>原价￥15.0元</span>
        </p>
        <yd-button type="danger" @click.native="searchBtn2()">点击查询</yd-button>
      </div>
    </div>

  </section>
</template>

<script>
  import wx from 'weixin-js-sdk';

  export default {
    name: "credit_search",
    data() {
      return {
        price1: '',
        price2: '',
        type:'',
      }
    },
    methods: {
      lookBtn1() {
        this.$router.push('/detail_img');
      },
      lookBtn2() {
        this.$router.push('/detail_img2');
      },
      searchBtn1() {
        if(this.type != undefined && this.type != ''){
          sessionStorage.setItem('DISTRIBUTORTYPE',this.type);
        }
        this.$router.push('/risk_report');
      },
      searchBtn2() {
        if(this.type != undefined && this.type != ''){
          sessionStorage.setItem('DISTRIBUTORTYPE',this.type);
        }
        this.$router.push('/risk_report_com');
      },
    },
    created() {
      let url = location.href.split('#')[0];
      let type = this.$route.query.type;
      const that = this;
      if (type != undefined) {
        this.type = type;
        this.$ajax.post(window.g.apiUrl+'/alipay/getProduct.do', JSON.stringify({
          type: type,
        })).then((response) => {
          if (response.data.code == 200) {
            let arr = response.data.data;
            switch (type) {
              case 'DYD':
                for (let [index, val] of arr.entries()) {
                  if (val.id == 201) {
                    that.price1 = val.price;
                  }
                  if (val.id == 202) {
                    that.price2 = val.price;
                  }
                }
                break;
            }
          } else {
            that.$dialog.notify({
              mes: '信息获取超时，请稍后重试',
              timeout: 1500,
            });
          }
        }).catch(() => {
        })
      }else{
        this.$ajax.post(window.g.apiUrl+'/alipay/getProduct.do', JSON.stringify({
          type: 'B',
        })).then((response) => {
          if (response.data.code == 200) {
            let arr = response.data.data;
                for (let [index, val] of arr.entries()) {
                  if (val.id == '27') {
                    that.price1 = val.price;
                  }
                  if (val.id == '35') {
                    that.price2 = val.price;
                  }
                }
          } else {
            that.$dialog.notify({
              mes: '信息获取超时，请稍后重试',
              timeout: 1500,
            });
          }
        }).catch(() => {
        })
      }
      let shareUrl = location.href;
      this.$ajax.post(window.g.apiUrl+'/user/signature.do', JSON.stringify({
        url: url,
      })).then((response) => {
        wx.config({
          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
          appId: response.data.data.appId, // 必填，公众号的唯一标识
          timestamp: response.data.data.timestamp, // 必填，生成签名的时间戳
          nonceStr: response.data.data.nonceStr, // 必填，生成签名的随机串
          signature: response.data.data.signature,// 必填，签名
          jsApiList: ["onMenuShareTimeline", "onMenuShareAppMessage"] // 必填，需要使用的JS接口列表
        });
        wx.ready(function () {
          wx.onMenuShareTimeline({
            title: '火炬数据 信用查询', // 分享标题
            link: shareUrl, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: 'https://www.huojudata.com/image/logo.jpg', // 分享图标
            success: function () {
              // 用户点击了分享后执行的回调函数
            },
          })
          wx.onMenuShareAppMessage({
            title: '火炬数据 信用查询', // 分享标题
            desc: '【火炬数据】让数据聚合价值    用科技成就未来', // 分享描述
            link: shareUrl, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
            imgUrl: 'https://www.huojudata.com/image/logo.jpg', // 分享图标
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
// 用户点击了分享后执行的回调函数
            }
          });
        });
      }).catch(() => {
      })
    }
  }
</script>

<style scoped>
  .part {
    width: 7rem;
    box-shadow: 1px 1px 5px 1px rgba(199, 199, 199, .8);
    margin: 20px auto;
    border-radius: 5px;
    padding-bottom: .25rem;
  }

  .tit {
    display: flex;
    padding-top: .4rem;
  }

  .title_index_img {
    width: .08rem;
    height: .4rem;
  }

  .tit span:nth-child(2) {
    margin-left: .3rem;
    font-size: .32rem;
    font-weight: bold;
  }

  .con {
    margin-top: .4rem;
    padding-left: .3rem;
    font-size: .24rem;
    color: #808080;
    width: 4rem;
    text-align: left;
    line-height: .36rem;
  }

  .look {
    color: #62B5F9;
    margin-top: .3rem;
    text-align: left;
    padding-left: .3rem;
    display: flex;
  }

  .look span {
    border-bottom: 1px solid #62B5F9;
  }

  .part_top {
    position: relative;
  }

  .img {
    width: 2.2rem;
    position: absolute;
    right: 0;
    top: .4rem;
  }

  .line {
    width: 6.4rem;
    height: 1px;
    background: #f2f2f2;
    margin: .25rem 0 .25rem .3rem;
  }

  .part_bot p span:nth-child(1) {
    font-weight: bold;
    color: #e72a26;
    font-size: .38rem;
  }

  .part_bot p span:nth-child(2) {
    font-weight: bold;
    font-size: .28rem;
    color: #e72a26;
    margin-right: .2rem;
  }

  .part_bot p span:nth-child(3) {
    font-size: .24rem;
    text-decoration: line-through;
    color: #808080;
  }

  .part_bot {
    display: flex;
    padding: 0 .3rem;
    align-items: center;
    justify-content: space-between;
  }
</style>
